import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [
  {
    //首页
    path: '/index',
    name: 'index',
    component: () => import('../views/Index.vue'),
    children: [
      {
        //home首页
        path: '/index/home',
        name: 'home',
        component: () => import('../views/Index/Home.vue'),
      },
      {
        //爆爆团
        path: '/index/tuan',
        name: 'tuan',
        component: () => import('../views/Index/Tuan.vue'),
      },
      {
        //订单
        path: '/index/order',
        name: 'order',
        component: () => import('../views/Index/Order.vue'),
      },
      {
        //我的
        path: '/index/mine',
        name: 'mine',
        component: () => import('../views/Index/Mine.vue'),
      },
      {
        //路由重定向
        path: '/index',
        redirect: '/index/home'
      },
      {
        //404错误路由
        path: '*',
        component: () => import('../views/NotFound.vue')
      }
    ]
  },
  {
    //详情
    path: '/detail/:id',
    name: 'detail',
    component: () => import('../views/Detail.vue')
  },
  {
    //登录
    path: '/login',
    name: 'login',
    component: () => import('../views/Login.vue')
  },
  {
    //注册
    path: '/register',
    name: 'register',
    component: () => import('../views/Register.vue')
  },
  {
    //路由重定向
    path: '/',
    redirect: '/index'
  },
  {
    //404错误路由
    path: '*',
    component: () => import('../views/NotFound.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
